<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>作业1，循环列表，点击更改颜色</title>

</head>

<body>
  <div id="app">
    <ul>
      <li v-for="(item,index) in list">
        <span v-bind:class="activeClass(index)">{{index}} - {{item}}</span>
      </li>
    </ul>
  </div>
  <script src="../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        list: ['小东', '小周', '小宏', '小新'],
        red: 'red'
      },
      methods: {
        activeClass: function(index) {
          return this.red;
        }
      }
    })
  </script>
  <style>
    .red {
      color: red;
    }
  </style>
</body>

</html>